$(function(){
	$('.detail_a_addlines').live('click',function(){
		$(this).parent().parent().next().next().hide();
		 $(this).parent().parent().next().slideToggle();
		 $(this).parent().parent().next().next().next().css('border-top','1px solid #dedede');
	});
	$('.facility_lines_a').live('click',function(){
		$(this).parent().parent().next().hide();
		 $(this).parent().parent().next().next().slideToggle();
		 $(this).parent().parent().next().next().next().css('border-top','1px solid #dedede');
	});
	$('.pwsj_right_byq_divbox .add_facility_box img').live('click',function(){
		$(this).parent().slideToggle();
		$(this).parent().next().next().css('border-top','none');
	});
	$('.pwsj_right_byq_divbox .add_lines_box img').live('click',function(){
		$(this).parent().slideToggle();
		$(this).parent().next().css('border-top','none');
	});
	goToPage(1);
});
function goToPage(pageNo){
	var deviceName = $('#deviceName').val();
	$.ajax({
		url : contextPath+ 'user/dygt/list',
		data : {
			parentDeviceId:parentDeviceId,
			deviceName:deviceName,
			pageSize:10,
			pageNo : pageNo
		},
		type : 'POST',
		success : function(list) {
			$(".pwsj_right_byq_divbox").empty();
			$(".page").empty();
			if(list!=null && list.totalRecord>0){
				var obj = list.records;
				for(var i=0;i<obj.length;i++){
					var div= '<ul class="byq_cont_ul">';
					div += '<li id="deviceBox" name="deviceBox" class="" style="width:4%;"><input type="checkbox" value="'+obj[i].deviceid+'" class="checkbox" /></li>';
					div += '<li style="width:12%;"><a href="'+contextPath+'user/d/dygtinfo.jsp?deviceid='+obj[i].deviceid+'">'+obj[i].devicename+'</a></li>';
					div += '<li style="width:12%;">'+(obj[i].physicaltowercode==null?"":obj[i].physicaltowercode)+'</li>';
					div += '<li style="width:12%;">'+(obj[i].predevicecode==null?"":obj[i].predevicecode)+'</li>';
					div += '<li style="width:4%;">'+(obj[i].operationstate==null?"":obj[i].operationstate)+'</li>';
					div += '<li style="width:8%;">'+(obj[i].linecode==null?"":obj[i].linecode)+'</li>';
					div += '<li style="width:4%;">'+(obj[i].towernature==null?"":obj[i].towernature)+'</li>';
					div += '<li style="width:4%;">'+(obj[i].span==null?"":obj[i].span)+'</li>';
					div += '<li style="width:4%;">'+(obj[i].isterminal==null?"":obj[i].isterminal)+'</li>';
					div += '<li style="width:4%;">'+(obj[i].model==null?"":obj[i].model)+'</li>';
					/*div += '<li style="width:4%;">'+(obj[i].sametowernumber==null?"":obj[i].sametowernumber)+'</li>';*/
					div += '<li class="operate" style="width:29%; border-right:none;">';
					//权限判断
					if(lowaddaction){
						div +=	'<a  class="detail_a_addlines">新增列表</a>';
					}
					if(true){
						div +=	'<a  class="facility_lines_a">设备列表</a>';
					}
					
					
					if(loweditaction){
						div += '<a href="'+contextPath+'user/d/dygtedite.jsp?deviceid='+obj[i].deviceid+'" class="detail_a_edite">编辑</a>';
					}
					if(lowdeleteaction){
						div += '<a  onclick="devicedel(\'dygt\',\''+obj[i].deviceid+'\',0,0)" class="detail_a_del">删除</a>';
					}
					div +=	'</li>';
					div += '</ul>';
					div += '<div class="add_facility_box" style="display:none;">';
					div += '<a href="'+contextPath+'user/d/dyzskgadd.jsp?deviceid='+obj[i].deviceid+'" class="add_facility_btn">新增柱上开关</a>';
					div += '<a href="'+contextPath+'user/d/dyzrdqadd.jsp?deviceid='+obj[i].deviceid+'" class="add_facility_btn">新增柱上熔断器</a>';
					div += '<a href="'+contextPath+'user/d/dyrsxadd.jsp?deviceid='+obj[i].deviceid+'" class="add_facility_btn">新增柱上熔丝箱</a>';
					div += '<a href="'+contextPath+'user/d/dyzsdrqadd.jsp?deviceid='+obj[i].deviceid+'" class="add_facility_btn">新增柱上电容器</a>';
					div += '<a href="'+contextPath+'user/d/dywgbczzadd.jsp?deviceid='+obj[i].deviceid+'" class="add_facility_btn">新增无功补偿装置</a>';
					div += '<a href="'+contextPath+'user/d/dyzsblqadd.jsp?deviceid='+obj[i].deviceid+'" class="add_facility_btn">新增柱上避雷器</a>';
					div += '<img src="../images/add_facility_close.png" alt="" /></div>';
					div += '<div class="add_lines_box" style="display:none;">';
					div += '<a href="'+contextPath+'user/d/dyzskglist.jsp?deviceid='+obj[i].deviceid+'" class="add_lines_btn">柱上开关列表</a>';
					div += '<a href="'+contextPath+'user/d/dyzrdqlist.jsp?deviceid='+obj[i].deviceid+'" class="add_lines_btn">柱上熔断器列表</a>';
					div += '<a href="'+contextPath+'user/d/dyrsxlist.jsp?deviceid='+obj[i].deviceid+'" class="add_lines_btn">柱上熔丝箱列表</a>';
					div += '<a href="'+contextPath+'user/d/dyzsdrqlist.jsp?deviceid='+obj[i].deviceid+'" class="add_lines_btn">柱上电容器列表</a>';
					div += '<a href="'+contextPath+'user/d/dywgbczzlist.jsp?deviceid='+obj[i].deviceid+'" class="add_lines_btn">柱上无功补偿装置列表</a>';
					div += '<a href="'+contextPath+'user/d/dyzsblqlist.jsp?deviceid='+obj[i].deviceid+'" class="add_lines_btn">柱上避雷器列表</a>';
					div += '<img src="../images/add_facility_close.png" alt="" /></div>';
					$(".pwsj_right_byq_divbox").append(div);
				}
				pageList(list);
			}
		}
	});
}